<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ### 通過時尚顧問ID和日期計算業績和提成 **位置:** Common\Lib\UserLib; **參數:** * @param $uid 時尚顧問的Id * @param $month 月份時間 **調用:** * $user = new UserLib(); * $result = $user->createCommission($uid, $month); **完整代碼:** ~~~ /* * 計算時尚顧問業績和提成 * @param $uid 時尚顧問Id * @param $month 月份時間 * * @return bool 計算是否成功 */ function createCommission ($uid, $month) { //1、獲取參數(計算時尚顧問銷售業績) $days = date("t", strtotime($month)); //計算出某年某月的天數 $map['list.create_time'] = array('between', array( strtotime($month), strtotime(trim($month) . '-' . $days . ' 23:59:59'))); M()->startTrans(); //2、基于時尚顧問查詢當月銷售業績 $map_results['sales_time'] = array('between', array( strtotime($month), strtotime(trim($month) . '-' . $days . ' 23:59:59'))); $map_results['is_delete'] = 0; $map_results['sales_uid'] = $uid; $results_sale = M('results_sales') ->field('id,sales_uid') ->where($map_results) ->select(); if (count($results_sale) < 1) { return array('success' => false, 'code' => 201, 'msg' => '該月沒有錄入時尚顧問業績目標!'); } //3、統計時尚顧問銷售業績 foreach ($results_sale as $key => $value) { // 增加一個判斷結算方式是否偽刪除的條件 $mapB['a.is_delete'] = array('eq', 0); // 3是禮券的結算方式id,禮券是不能算業績的 // $mapB['a.pay_id'] = array('neq',3); $mapB['a.create_time'] = array('between', array( strtotime($month), strtotime(trim($month) . '-' . $days . ' 23:59:59'))); $mapB['a.sales_uid'] = $value['sales_uid']; // 計算財務審核后得到每個小票單的業績金額 $sales = M('order_sales as a') ->field('id,sales_money') ->where($mapB) ->select(); $sales_total = 0; foreach ($sales as $k => $v) { $sales_total += $v['sales_money']; } $save_sale = M('results_sales') ->where(array('id' => $value['id'])) ->save(array('sales_total' => $sales_total)); if ($save_sale === false) { M()->rollback(); return array('success' => false, 'code' => 201, 'msg' => '銷售用戶銷售總金額保存失敗'); } } //3、根據規則計算時尚顧問業績提成 $where['list.create_time'] = array('between', array( strtotime($month), strtotime(trim($month) . '-' . $days . ' 23:59:59'))); $results_sale = M('results_sales') ->where($map_results) ->select(); foreach ($results_sale as $key => $value) { $sales_describe = array(); $money_a = 0; //該類銷售金額 $money_b = 0; //該類銷售業績 //2.1、循環計算時尚顧問完成率 $results_rate = $value['sales_total'] / $value['sales_target']; //2.2、根據算的完成率查詢適合的業績計算規則 if ($results_rate >= 0.5 && $results_rate < 0.75) { $results_rates = 0.5; } elseif ($results_rate >= 0.75 && $results_rate < 1) { $results_rates = 0.75; } elseif ($results_rate >= 1 && $results_rate < 1.25) { $results_rates = 1; } elseif ($results_rate > 1.25) { $results_rates = 1.25; } array_push($sales_describe, '個人業績完成率為:' . $this->getPercent($results_rate)); $whereA['start_time'] = array('elt', strtotime(trim($month) . '-01')); $whereA['end_time'] = array('egt', strtotime(trim($month) . '-' . $days)); $whereA['is_delete'] = 0; $rule_list = M('results_rules') ->where($whereA) ->select(); foreach ($rule_list as $k => $v) { $brang_name = $v['rule_name']; //針對性的過濾 if (($results_rate < 0.5) && !in_array($brang_name, array('自由品牌', '設計師品牌'))) { continue; } $brand_sum = 0; //記錄每條規則業績 $t_money = 0; //記錄每條規則提成 $whereB = array(); $whereC = array(); $brands = json_decode($v['brand_id']); $cat_ids = json_decode($v['cat_id']); $percent = object_to_array(json_decode($v['percent'])); //針對性取提點 if (in_array($brang_name, array('自由品牌', '設計師品牌'))) { $abs = '0.5'; $bai = $percent[$abs]; } else { $abd = strval($results_rates); $bai = $percent[$abd]; } if ($v['is_in'] == 1) { $is_in = 'in'; } elseif ($v['is_in'] == 2) { $is_in = 'not in'; } //有品牌的邏輯 if (count($brands) > 0) { foreach ($brands as $kk => $vv) { $a = ''; $string = ''; if (!empty($vv)) { $whereB['a.brand_id'] = $vv; $brand_name = get_brand_en($vv); $a .= $brand_name; } if (!empty($cat_ids)) { $cat_arr = array(); $is_ins = $v['is_in'] == 1 ? '包含' : '不包含'; $a .= $is_ins; foreach ($cat_ids as $kkk => $vvv) { if (!empty($vvv)) { $cat_info = M('goods_category') ->where(array('id' => $vvv)) ->find(); $whereB['e.level'] = $cat_info['level']; array_push($cat_arr, $vvv); $mall_obj = new MallLib(); $cat_name = $mall_obj->getChFullPath($vvv); $a .= $cat_name; } } $whereB['e.cat_id'] = array($is_in, $cat_arr); } $whereB['a.is_delete'] = 0; $whereB['e.is_delete'] = 0; $spu_ids = M('goods_spu as a') ->field('a.id') ->join('coscia_goods_spu_category as e on e.spu_id = a.id', 'left') ->where($whereB) ->select(); if (empty($spu_ids)) { continue; } if (!empty($spu_ids)) { $spu_where = array(); foreach ($spu_ids as $kk => $vv) { array_push($spu_where, $vv['id']); } $whereC['a.spu_id'] = array('in', $spu_where); } //查詢對應品牌和品類的銷售業績金額 $whereC['a.create_time'] = array('between', array( strtotime($month), strtotime(trim($month) . '-' . $days . ' 23:59:59'))); $whereC['b.sale_uid'] = $value['sales_uid']; $whereC['b.order_status'] = array('not in', array(1, 6, 15, 16, 7)); $data = M('order_sku as a') ->field('a.sku_id,a.goods_num,a.subtotal,a.create_time') ->join('coscia_order_list as b on a.order_id = b.id', 'left') ->where($whereC) ->select(); //如果該分類沒有銷售記錄就過掉 if (empty($data)) { continue; } else { $string .= $a; //該業績規則銷售金額匯總 $money_sum = 0; foreach ($data as $kkk => $vvv) { $money_sum += $vvv['subtotal']; } $money_a += $money_sum; $brand_sum += $money_sum; //計算該業績規則下業績提成 $money_result = round($money_sum * $bai, 2); $money_b += $money_result; $t_money += $money_result; $string .= '銷售業績' . $money_sum . ',銷售提成:' . $money_sum . '*' . ($bai * 100) . '%=' . $money_result; array_push($sales_describe, $string); } } } else { if (!empty($cat_ids)) { foreach ($cat_ids as $kkk => $vvv) { $a = ''; $string = ''; $cat_arr = array(); $is_ins = $v['is_in'] == 1 ? '包含' : '不包含'; $a .= $is_ins; if (!empty($vvv)) { $cat_info = M('goods_category') ->where(array('id' => $vvv)) ->find(); $whereB['e.level'] = $cat_info['level']; array_push($cat_arr, $vvv); $whereB['e.cat_id'] = array($is_in, $cat_arr); $mall_obj = new MallLib(); $cat_name = $mall_obj->getChFullPath($vvv); $a .= $cat_name; } $whereB['a.is_delete'] = 0; $whereB['e.is_delete'] = 0; $spu_ids = M('goods_spu as a') ->field('a.id') ->join('coscia_goods_spu_category as e on e.spu_id = a.id', 'left') ->where($whereB) ->select(); if (empty($spu_ids)) { continue; } if (!empty($spu_ids)) { $spu_where = array(); foreach ($spu_ids as $kk => $vv) { array_push($spu_where, $vv['id']); } $whereC['a.spu_id'] = array('in', $spu_where); } //查詢對應品牌和品類的銷售業績金額 $whereC['a.create_time'] = array('between', array( strtotime($month), strtotime(trim($month) . '-' . $days . ' 23:59:59'))); $whereC['b.sale_uid'] = $value['sales_uid']; $whereC['b.order_status'] = array('not in', array(1, 6, 15, 16, 7)); $data = M('order_sku as a') ->field('a.sku_id,a.goods_num,a.subtotal,a.create_time') ->join('coscia_order_list as b on a.order_id = b.id', 'left') ->where($whereC) ->select(); //如果該分類沒有銷售記錄就過掉 if (empty($data)) { continue; } else { $string .= $a; //該業績規則銷售金額匯總 $money_sum = 0; foreach ($data as $kkk => $vvv) { $money_sum += $vvv['subtotal']; } $money_a += $money_sum; $brand_sum += $money_sum; //計算該業績規則下業績提成 $money_result = round($money_sum * $bai, 2); $money_b += $money_result; $t_money += $money_result; $string .= '銷售業績' . $money_sum . ',銷售提成:' . $money_sum . '*' . ($bai * 100) . '%=' . $money_result; array_push($sales_describe, $string); } } } } if ($brand_sum != 0) { array_push($sales_describe, $brang_name . '總銷售業績:' . $brand_sum); array_push($sales_describe, $brang_name . '總銷售提成:' . $t_money); array_push($sales_describe, ''); } } //把時尚顧問銷售業績信息存到銷售業績信息表 $save_sales = M('results_sales') ->where(array('id' => $value['id'])) ->save(array('sales_amount' => $money_b, 'sales_describe' => json_encode($sales_describe))); if ($save_sales === false) { M()->rollback(); return array('success' => false, 'code' => 201, 'msg' => get_user_name($value['sales_uid'], 1) . '的業績信息保存失敗'); } } M()->commit(); return array('success' => true, 'code' => 200, 'msg' => '數據生成成功!'); } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看