OrderService.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | framework
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://framework.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/framework
  12. // +----------------------------------------------------------------------
  13. namespace app\store\service;
  14. use think\Db;
  15. /**
  16. * 订单服务管理器
  17. * Class OrderService
  18. * @package app\store\service
  19. */
  20. class OrderService
  21. {
  22. /**
  23. * 根据订单号升级会员等级
  24. * @param string $order_no 订单单号
  25. * @return boolean
  26. * @throws \think\db\exception\DataNotFoundException
  27. * @throws \think\db\exception\ModelNotFoundException
  28. * @throws \think\exception\DbException
  29. */
  30. public static function update($order_no)
  31. {
  32. // @todo 更新订单状态
  33. }
  34. /**
  35. * 根据订单同步库存销量
  36. * @param string $order_no
  37. * @return boolean
  38. * @throws \think\Exception
  39. * @throws \think\db\exception\DataNotFoundException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. * @throws \think\exception\DbException
  42. * @throws \think\exception\PDOException
  43. */
  44. public static function syncStock($order_no)
  45. {
  46. $map = ['order_no' => $order_no];
  47. $goodsIds = Db::name('StoreOrderList')->where($map)->column('goods_id');
  48. foreach (array_unique($goodsIds) as $goodsId) if (!GoodsService::syncStock($goodsId)) return false;
  49. return true;
  50. }
  51. /**
  52. * 订单利润计算
  53. * @param string $order_no
  54. * @return boolean
  55. */
  56. public static function profit($order_no = '')
  57. {
  58. // @todo 计算订单返佣
  59. }
  60. }