|
@@ -6,6 +6,7 @@ use app\admin\validate\member\RuleAddedValidate;
|
|
|
use app\admin\validate\member\RulePricingValidate;
|
|
|
use app\controller\Curd;
|
|
|
use app\model\RuleAdded;
|
|
|
+use app\model\RuleAddedComponent;
|
|
|
use app\model\RulePricing;
|
|
|
use app\model\SysSerial;
|
|
|
use support\exception\BusinessException;
|
|
@@ -40,6 +41,36 @@ class RuleAddedController extends Curd
|
|
|
return json_success('', $data);
|
|
|
}
|
|
|
|
|
|
+ public function info(Request $request): Response
|
|
|
+ {
|
|
|
+ $id = $request->get('rule_added_id');
|
|
|
+ $added = RuleAdded::find($id);
|
|
|
+ if (!$added) {
|
|
|
+ return json_fail('数据不存在');
|
|
|
+ }
|
|
|
+
|
|
|
+ $components = RuleAddedComponent::with(['goods', 'sku'])
|
|
|
+ ->where('join_component_rule_added_id', $id)
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ foreach ($components as &$component) {
|
|
|
+ if (!empty($component['sku']) && !empty($component['sku']['goods_sku_specs_json'])) {
|
|
|
+ $specsJson = json_decode($component['sku']['goods_sku_specs_json'], true);
|
|
|
+ $skuTitle = '';
|
|
|
+ foreach ($specsJson as $item) {
|
|
|
+ if (is_array($item)) {
|
|
|
+ $item = implode(',', $item);
|
|
|
+ }
|
|
|
+ $skuTitle .= $item . '-';
|
|
|
+ }
|
|
|
+ $skuTitle = rtrim($skuTitle, '-');
|
|
|
+ $component['sku']['goods_sku_title'] = $skuTitle;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return json_success('', $components);
|
|
|
+ }
|
|
|
+
|
|
|
protected function insertInput(Request $request): array
|
|
|
{
|
|
|
$data = $this->inputFilter($request->post());
|
|
@@ -53,11 +84,11 @@ class RuleAddedController extends Curd
|
|
|
$primary_key = $this->model->getKeyName();
|
|
|
$id = $request->post($primary_key);
|
|
|
$data = $this->inputFilter($request->post());
|
|
|
- if (!empty($data['rule_pricing_goods_json'])) {
|
|
|
- $data['rule_pricing_goods_json'] = json_encode(explode(',', $data['rule_pricing_goods_json']));
|
|
|
- } else {
|
|
|
- $data['rule_pricing_goods_json'] = '[]';
|
|
|
- }
|
|
|
+// if (!empty($data['rule_pricing_goods_json'])) {
|
|
|
+// $data['rule_pricing_goods_json'] = json_encode(explode(',', $data['rule_pricing_goods_json']));
|
|
|
+// } else {
|
|
|
+// $data['rule_pricing_goods_json'] = '[]';
|
|
|
+// }
|
|
|
$model = $this->model->find($id);
|
|
|
if (!$model) {
|
|
|
throw new BusinessException('记录不存在', 2);
|