Viporder.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class Viporder extends Model
  5. {
  6. protected $connection = 'mysql';
  7. protected $pk = 'id';
  8. protected $name = 'viporder';
  9. static public function pay_order($params)
  10. {
  11. $order_num_alias = $params['order_num_alias'];
  12. $order_info = self::where(['order_num_alias' => $order_num_alias])->find();
  13. Member::where('id', $order_info['uid'])->update(['gid' => $order_info['gid']]);
  14. $MemberAG = MemberAuthGroup::find($order_info['gid']);
  15. if (!empty($MemberAG)) {
  16. $order['id'] = $order_info['id'];
  17. $order['pay_time'] = time();
  18. if ($MemberAG->start_time > 0) {
  19. $order['begin_time'] = strtotime("+" . $MemberAG->start_time . " hours");
  20. }
  21. if ($MemberAG->expire_day > 0) {
  22. $order['end_time'] = strtotime("+" . $MemberAG->expire_day . " months");
  23. }
  24. self::update($order);
  25. if (!empty($MemberAG->coupon_id) && !empty($MemberAG->number)) {
  26. $Coupondata = Coupon::where(['weid' => weid(), 'id' => $MemberAG->coupon_id])->find();
  27. if (!empty($Coupondata)) {
  28. $Coupondata = $Coupondata->toArray();
  29. unset($Coupondata['id']);
  30. $Coupondata['uid'] = $order_info['uid'];
  31. $Coupondata['coupon_id'] = $MemberAG->coupon_id;
  32. $Coupondata['number'] = $MemberAG->number;
  33. //Test::create(['info' => serialize($Coupondata)]);
  34. $r = CouponReceive::create($Coupondata);
  35. }
  36. }
  37. }
  38. }
  39. }