|
|
@@ -26,11 +26,43 @@ class GoodsClass extends BaseClass
|
|
|
|
|
|
public static function cgPlant($data)
|
|
|
{
|
|
|
+ //[{"goodsId":"1486","num":"1","price":"2"}]
|
|
|
$goodsData = $data['goods'] ?? '';
|
|
|
if (empty($goodsData)) {
|
|
|
- util::fail('没有商品');
|
|
|
+ $name = $data['name'] ?? '';
|
|
|
+ if (empty($name)) {
|
|
|
+ util::fail('请填写名称');
|
|
|
+ }
|
|
|
+ $salePrice = $data['salePrice'] ?? 0;
|
|
|
+ $sjId = $data['sjId'] ?? 0;
|
|
|
+ $shopId = $data['shopId'] ?? 0;
|
|
|
+ $mainId = $data['mainId'] ?? 0;
|
|
|
+ $status = $data['status'] ?? 0;
|
|
|
+ $delStatus = $data['delStatus'] ?? 0;
|
|
|
+ $num = $data['num'] ?? 0;
|
|
|
+ $cgPrice = $data['cgPrice'] ?? 0;
|
|
|
+ $sendCost = $data['sendCost'] ?? 0;
|
|
|
+ $shopImg = $data['shopImg'] ?? [];
|
|
|
+ if ($sendCost > 0) {
|
|
|
+ $div = bcmul($sendCost, $num, 2);
|
|
|
+ $cgPrice = bcadd($cgPrice, $div, 2);
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'name' => $name,
|
|
|
+ 'flower' => 0,
|
|
|
+ 'property' => 0,
|
|
|
+ 'price' => $salePrice,
|
|
|
+ 'sjId' => $sjId,
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'status' => $status,
|
|
|
+ 'delStatus' => $delStatus,
|
|
|
+ 'shopImg' => $shopImg,
|
|
|
+ ];
|
|
|
+ $respond = self::addGoods($data);
|
|
|
+ $goodsId = $respond->id ?? 0;
|
|
|
+ $goodsData = json_encode(['goodsId' => $goodsId, 'num' => $num, 'price' => $cgPrice]);
|
|
|
}
|
|
|
- //[{"goodsId":"1486","num":"1","price":"2"}]
|
|
|
$goodsData = json_decode($goodsData, true);
|
|
|
if (empty($goodaInfo) || is_array($goodsData)) {
|
|
|
util::fail('没有找到商品');
|
|
|
@@ -216,41 +248,43 @@ class GoodsClass extends BaseClass
|
|
|
GoodsCategoryClass::add($addCategory);
|
|
|
CategoryClass::counters(['goodsNum' => 1], ['id' => $catId]);
|
|
|
}
|
|
|
- $workSn = $work->workSn ?? '';
|
|
|
- $workItemList = WorkItemClass::getAllByCondition(['workSn' => $workSn], null, '*', null, true);
|
|
|
- if (empty($workItemList)) {
|
|
|
- util::fail('没有找到工单的花材');
|
|
|
- }
|
|
|
- foreach ($workItemList as $item) {
|
|
|
- $itemId = $item->itemId ?? 0;
|
|
|
- $ptItemId = $item->ptItemId ?? 0;
|
|
|
- $num = $item->num ?? 0;
|
|
|
- $count = $item->count ?? 0;
|
|
|
- $ratio = $item->ratio ?? 0;
|
|
|
- $bigName = $item->bigName ?? '';
|
|
|
- $smallName = $item->smallName ?? '';
|
|
|
- $unitType = $item->unitType ?? 0;
|
|
|
- $unitName = $item->unitName ?? 0;
|
|
|
- $currentName = $item->name ?? '';
|
|
|
- $cover = $item->cover ?? '';
|
|
|
- $goodsItemData = [
|
|
|
- 'name' => $currentName,
|
|
|
- 'cover' => $cover,
|
|
|
- 'sjId' => $sjId,
|
|
|
- 'shopId' => $shopId,
|
|
|
- 'mainId' => $mainId,
|
|
|
- 'goodsId' => $id,
|
|
|
- 'itemId' => $itemId,
|
|
|
- 'ptItemId' => $ptItemId,
|
|
|
- 'num' => $num,
|
|
|
- 'count' => $count,
|
|
|
- 'ratio' => $ratio,
|
|
|
- 'bigName' => $bigName,
|
|
|
- 'smallName' => $smallName,
|
|
|
- 'unitType' => $unitType,
|
|
|
- 'unitName' => $unitName,
|
|
|
- ];
|
|
|
- GoodsItemClass::addData($goodsItemData);
|
|
|
+ if (!empty($work)) {
|
|
|
+ $workSn = $work->workSn ?? '';
|
|
|
+ $workItemList = WorkItemClass::getAllByCondition(['workSn' => $workSn], null, '*', null, true);
|
|
|
+ if (empty($workItemList)) {
|
|
|
+ util::fail('没有找到工单的花材');
|
|
|
+ }
|
|
|
+ foreach ($workItemList as $item) {
|
|
|
+ $itemId = $item->itemId ?? 0;
|
|
|
+ $ptItemId = $item->ptItemId ?? 0;
|
|
|
+ $num = $item->num ?? 0;
|
|
|
+ $count = $item->count ?? 0;
|
|
|
+ $ratio = $item->ratio ?? 0;
|
|
|
+ $bigName = $item->bigName ?? '';
|
|
|
+ $smallName = $item->smallName ?? '';
|
|
|
+ $unitType = $item->unitType ?? 0;
|
|
|
+ $unitName = $item->unitName ?? 0;
|
|
|
+ $currentName = $item->name ?? '';
|
|
|
+ $cover = $item->cover ?? '';
|
|
|
+ $goodsItemData = [
|
|
|
+ 'name' => $currentName,
|
|
|
+ 'cover' => $cover,
|
|
|
+ 'sjId' => $sjId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'goodsId' => $id,
|
|
|
+ 'itemId' => $itemId,
|
|
|
+ 'ptItemId' => $ptItemId,
|
|
|
+ 'num' => $num,
|
|
|
+ 'count' => $count,
|
|
|
+ 'ratio' => $ratio,
|
|
|
+ 'bigName' => $bigName,
|
|
|
+ 'smallName' => $smallName,
|
|
|
+ 'unitType' => $unitType,
|
|
|
+ 'unitName' => $unitName,
|
|
|
+ ];
|
|
|
+ GoodsItemClass::addData($goodsItemData);
|
|
|
+ }
|
|
|
}
|
|
|
return $info;
|
|
|
}
|