AuctionDeliver.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. namespace app\admin\controller\auction;
  3. use app\admin\controller\AuthController;
  4. use app\admin\controller\Union;
  5. use app\admin\model\user\User;
  6. use app\admin\model\user\UserBill;
  7. use crmeb\services\{ExpressService,
  8. JsonService,
  9. MiniProgramService,
  10. upload\Upload,
  11. WechatService,
  12. FormBuilder as Form,
  13. CacheService,
  14. UtilService as Util,
  15. JsonService as Json};
  16. use app\admin\model\system\{Express, SystemAttachment as SystemAttachmentModel, SystemAttachmentCategory as Category};
  17. use app\admin\model\auction\AuctionDeliver as model;
  18. use think\facade\Route as Url;
  19. use think\facade\Validate;
  20. /**
  21. * 竞拍管理
  22. * Class StoreOrder
  23. * @package app\admin\controller\store
  24. */
  25. class AuctionDeliver extends AuthController
  26. {
  27. public function index()
  28. {
  29. return $this->fetch();
  30. }
  31. /**
  32. * 获取列表
  33. * @return void
  34. */
  35. public function list()
  36. {
  37. $where = Util::getMore([
  38. ['page', 1],
  39. ['limit', 20],
  40. ['name', ''],
  41. ['product', ''],
  42. ['status', '']
  43. ]);
  44. $data = model::list($where);
  45. return Json::successlayui($data);
  46. }
  47. public function edit($id)
  48. {
  49. if (!$id) Json::fail('数据不存在');
  50. $data = \app\admin\model\auction\AuctionDeliver::find($id);
  51. $f = [];
  52. $f[] = Form::input('real_name', '用户姓名', $data->getData('real_name'))->col(12);
  53. $f[] = Form::input('user_phone', '用户手机号', $data->getData('user_phone'))->col(12);
  54. $f[] = Form::input('user_address', '用户收货地址', $data->getData('user_address'))->col(12);
  55. $form = Form::make_post_form('修改', $f, Url::buildUrl('update', compact('id')));
  56. $this->assign(compact('form'));
  57. return $this->fetch('public/form-builder');
  58. }
  59. public function update()
  60. {
  61. $data = Util::postMore([
  62. 'id',
  63. 'real_name',
  64. 'user_phone',
  65. 'user_address',
  66. ]);
  67. $validate = Validate::rule([
  68. 'real_name' => 'require',
  69. 'user_phone' => 'require',
  70. 'user_address' => 'require'
  71. ]);
  72. $validate->message([
  73. 'real_name.require' => '收货人姓名不能为空',
  74. 'user_phone.require' => '收货人手机号不能为空',
  75. 'user_address.require' => '收货地址不能为空',
  76. ]);
  77. if (!$validate->check($data)) {
  78. return Json::fail($validate->getError());
  79. }
  80. $res = \app\admin\model\auction\AuctionDeliver::update($data);
  81. if ($res){
  82. return Json::success('修改成功!');
  83. }else{
  84. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  85. }
  86. }
  87. /*
  88. * 发送货
  89. * @param int $id
  90. * @return html
  91. * */
  92. public function order_goods($id = 0)
  93. {
  94. $list = Express::where('is_show', 1)->order('sort desc')->column('name', 'id');
  95. $this->assign([
  96. 'list' => $list,
  97. 'id' => $id
  98. ]);
  99. return $this->fetch();
  100. }
  101. /**
  102. * TODO 送货信息提交
  103. * @param Request $request
  104. * @param $id
  105. */
  106. public function update_delivery($id = 0)
  107. {
  108. $data = Util::postMore([
  109. ['delivery_name', ''],
  110. ['delivery_id', ''],
  111. ], $this->request);
  112. $deliver = \app\admin\model\auction\AuctionDeliver::where('id', $id)->find();
  113. if ($deliver['status'] == 2) return Json::fail('已收货无法修改');
  114. $deliver['delivery_name'] = $data['delivery_name'];
  115. $deliver['delivery_id'] = $data['delivery_id'];
  116. $deliver['status'] = 1;
  117. $deliver['goods_time'] = time();
  118. $deliver->save();
  119. //短信发送
  120. event('ShortMssageSend', [\app\admin\model\auction\AuctionDeliver::where('id', $id)->value('name'), 'Deliver']);
  121. return Json::successful('成功!');
  122. }
  123. }