|
|
@@ -475,15 +475,22 @@ class orderSn
|
|
|
}
|
|
|
|
|
|
//商品有效编号1-开头 ssh 20220405
|
|
|
- public static function getGoodsSn()
|
|
|
- {
|
|
|
- $prefix = '1-';
|
|
|
- $respond = GoodsSnClass::add(['id' => null]);
|
|
|
- $id = $respond['id'] ?? 0;
|
|
|
- if (empty($id)) {
|
|
|
- util::fail('单号没有生成');
|
|
|
- }
|
|
|
- return $prefix . $id;
|
|
|
+ public static function getGoodsSn($data)
|
|
|
+ {
|
|
|
+ $mainId = $data['mainId'] ?? 0;
|
|
|
+ $shopId = $data['shopId'] ?? 0;
|
|
|
+ $info = GoodsSnClass::getByCondition(['mainId' => $mainId], true, 'sn DESC', 'id,sn');
|
|
|
+ if (empty($info)) {
|
|
|
+ $sn = 1;
|
|
|
+ } else {
|
|
|
+ $sn = $info->sn ?? 1;
|
|
|
+ $sn++;
|
|
|
+ }
|
|
|
+ $respond = GoodsSnClass::add(['id' => null, 'mainId' => $mainId, 'shopId' => $shopId, 'sn' => $sn]);
|
|
|
+ if (empty($respond)) {
|
|
|
+ util::fail('商品编号生成失败');
|
|
|
+ }
|
|
|
+ return $sn;
|
|
|
}
|
|
|
|
|
|
//二批采购退款 ssh 20220909
|