截流自动化的商城平台
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

AwardIntegral.php 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\common\command;
  20. use app\common\enum\OrderEnum;
  21. use app\common\logic\AccountLogLogic;
  22. use app\common\model\AccountLog;
  23. use app\common\model\order\Order;
  24. use app\common\model\user\User;
  25. use app\common\server\ConfigServer;
  26. use think\console\Command;
  27. use think\console\Input;
  28. use think\console\Output;
  29. use think\facade\Log;
  30. class AwardIntegral extends Command
  31. {
  32. protected function configure()
  33. {
  34. $this->setName('award_integral')
  35. ->setDescription('结算消费赠送积分');
  36. }
  37. protected function execute(Input $input, Output $output)
  38. {
  39. try {
  40. $time = time();
  41. $config = ConfigServer::get('transaction', 'order_after_sale_days', 7);
  42. $finish_limit = $config * 24 * 60 * 60;
  43. $orders = Order::field(true)->where([
  44. ['del', '=', 0],
  45. ['award_integral_status', '>', 0],
  46. ['is_award_integral', '=', 0],
  47. ['pay_status', '=', 1]
  48. ])->select()->toArray();
  49. foreach ($orders as $order) {
  50. if ($order['award_integral'] <= 0) {
  51. continue;
  52. }
  53. if ($order['award_integral_status'] == OrderEnum::ORDER_DELIVERY && $order['order_status'] < OrderEnum::ORDER_STATUS_GOODS) {
  54. continue;
  55. }
  56. if ($order['award_integral_status'] == OrderEnum::ORDER_FINISH && $order['order_status'] < OrderEnum::ORDER_STATUS_COMPLETE) {
  57. continue;
  58. }
  59. if ($order['award_integral_status'] == OrderEnum::ORDER_AFTER_SALE_OVER && ($order['order_status'] < OrderEnum::ORDER_STATUS_COMPLETE || ($finish_limit + $order['confirm_take_time']) > $time)) {
  60. continue;
  61. }
  62. User::where('id',$order['user_id'])->inc('user_integral', $order['award_integral'])->update();
  63. Order::update(['is_award_integral'=>1,'update_time'=>$time],['id'=>$order['id']]);
  64. AccountLogLogic::AccountRecord($order['user_id'], $order['award_integral'], 1, AccountLog::consume_award_integral, '', $order['id'], $order['order_sn']);
  65. }
  66. return true;
  67. } catch (\Exception $e) {
  68. Log::write('结算消费赠送积分异常:'.$e->getMessage());
  69. return false;
  70. }
  71. }
  72. }