Order.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\youzan\logic;
  3. use app\admin\model\ActionLog;
  4. use app\admin\model\GoodLog;
  5. use app\admin\model\ProcessOrder;
  6. use app\youzan\model\PlatformYouzan;
  7. use think\Exception;
  8. use think\facade\Cache;
  9. use think\facade\Db;
  10. //有赞订单类
  11. class Order
  12. {
  13. //获取有赞订单列表
  14. public static function getYzOrderList(array $data = [])
  15. {
  16. if (isset($data['platform_name']) && $data['platform_name'] != '') {
  17. $data['skuCodes'] = Db::name('platform_youzan')
  18. ->alias('py')
  19. ->leftJoin('platform p', 'p.id=py.platform_id AND p.is_del=0')
  20. ->whereLike('p.platform_name', '%' . $data['platform_name'] . '%')
  21. ->column('py.skuCode');
  22. }
  23. $res = curl_request(config('app.yz_domain') . 'api/yz_order_list', $data);
  24. $res = json_decode($res, true);
  25. if ($res['code'] == 0) return app_show(0, $res['message'], $res['data']);
  26. else return error_show($res['code'], $res['message']);
  27. }
  28. //有赞订单审核
  29. public static function checkStatus(array $data = [])
  30. {
  31. if (in_array($data['status'], [3, 5]) && $data['reason'] == '') return error_show(1005, '请填写驳回原因');
  32. //用户信息
  33. $userinfo = GetUserInfo($data['token']);
  34. $uid = isset($userinfo['data']['id']) ? $userinfo['data']['id'] : 0;
  35. $uname = isset($userinfo['data']['nickname']) ? $userinfo['data']['nickname'] : '';
  36. $res = curl_request(config('app.yz_domain') . 'api/yz_check_status', array_merge($data, ['uid' => $uid, 'uname' => $uname]));
  37. $res = json_decode($res, true);
  38. if ($res['code'] == 0) {
  39. //修改状态,添加待办
  40. ActionLog::logAdd(['id' => $uid, 'nickname' => $uname], [
  41. "order_code" => $res['data']['skuCode'],
  42. "status" => $res['data']['old_status'],//这里的status是之前的值
  43. "action_remark" => '',//备注
  44. "action_type" => "status"//新建create,编辑edit,更改状态status
  45. ], "YZQRD", 0, $data);
  46. //取符合条件的角色下的所有人
  47. $action_process_id = Db::name('action_process')
  48. ->where(['order_type' => 'YZQRD', 'order_process' => $data['status']])
  49. ->value('id', 0);
  50. $roleids = Db::name('role_process')
  51. ->where('is_del', 0)
  52. ->where('role_id', '<>', 1)//排除超级管理员
  53. ->whereFindInSet('action_data', $action_process_id)
  54. ->field('role_id')
  55. ->buildSql();
  56. //根据角色id筛选用户id
  57. $uids = Db::name('user_role')
  58. ->where(['is_del' => 0, 'status' => 1])
  59. ->where('roleid IN ' . $roleids)
  60. ->column('uid');
  61. ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $uname], [
  62. "order_type" => 'YZQRD',
  63. "order_code" => $res['data']['skuCode'],
  64. "order_id" => $data['id'],
  65. "order_status" => $data['status'],
  66. "before_status" => $res['data']['old_status'],
  67. 'handle_user_list' => implode(',', $uids)
  68. ]);
  69. return app_show(0, '操作成功');
  70. } else return error_show(1005, $res['message']);
  71. }
  72. }